/**
 * Copyright (C)  Gadglet .
 *
 * This file is part of Gadglet
 *
 * Gadglet is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Gadglet is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Gadglet. If not, see <http://www.gnu.org/licenses/>.
 */

package com.gadglet.client.gwt.google;


import com.gadglet.client.gwt.ui.DebugDialogBox;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;

public  class FeedResultsHeader{
	private String totalResults;
	private String  startIndex;
	private String itemsPerPage;
	DebugDialogBox errorNotifier = DebugDialogBox.getErrorNotifier();
	 FeedResultsHeader(JsArray<JavaScriptObject> data)
	{
		 	JSONArray entryArray = null;
			JSONObject entry = null;
					 
			try 
			{
				totalResults = (new JSONObject(data)).get("feed").isObject().get("openSearch$totalResults").isString().stringValue();
				startIndex = (new JSONObject(data)).get("feed").isObject().get("openSearch$startIndex").isString().stringValue();
				itemsPerPage = (new JSONObject(data)).get("feed").isObject().get("openSearch$itemsPerPage").isString().stringValue();
				
			}
			catch (Exception e) 
			{
			
				errorNotifier.showError(1,e.getMessage()) ;      	 
			}
	}

		public int getTotalResults() {
			int result = 0;
			
			try {
				result = Integer.parseInt(totalResults);
			} catch (NumberFormatException e) {
				
				
			}
		   return result;
		}

		public int getStartIndex() {
			
			int result = 0;
			
			try {
				result = Integer.parseInt(startIndex);
			} catch (NumberFormatException e) {
				
				
			}
		   return result;
		}

		public int getItemsPerPage() {
		
			int result = 0;
			
			try {
				result = Integer.parseInt(itemsPerPage);
			} catch (NumberFormatException e) {
				
				
			}
		   return result;
		}

}
